﻿<!DOCTYPE html>
<html>
	<head>
		<title>表列表</title>
        $css()
	</head>
	<body>
	 <div class="tabarea">

    <div class="tab_mini">
        <a href="javascript:;" class="current">所有表</a>
        <a href="?module=table&amp;action=create">创建表</a>
    </div>

    <table class="ui-table" cellspacing="0" cellpadding="0" id="gd">
      <tr>
        <th width="70">表格编号</th>
        <th width="100">表名</th>
        <th width="90">列(点击编辑)</th>
        <th width="90">行(点击查看)</th>
        <th width="60">启用</th>
        <th width="60">系统</th>
        <th>接口URL</th>
        <th width="60">浏览</th>
        <th width="40">修改</th>
        <th width="40">删除</th>
      </tr>
      ${tableListHtml}
    </table>
    <div class="ui-table-meta">共${count}个表格</div>

</div>
$js()
<script type="text/javascript">

    var md;
    window.onload = function () {
        jr.table.dynamic(document.getElementsByTagName("table")[0]);

        var bts = jr.$("gd", "button");
        for (var i in bts) {
            switch (bts[i].className) {
                case 'draw': bts[i].onclick = createColumn; break;
                case 'edit': bts[i].onclick = editTable; break;
                case 'delete': bts[i].onclick = deleteRecord; break;
            }
        }
    };
    function editTable() {
        location.replace(location.search.replace('all', 'edittable') + '&table_id=' + getId(this));
    }
    function deleteRecord() {
        if (confirm('确定删除吗?删除后将不可恢复!')) {
            var td = this.parentNode.parentNode;
            var id = getId(this);
            jr.xhr.post('?module=table&action=deletetable', "table_id=" + id,
                function (x) {
                    var msg = '';
                    var resultTag; eval('resultTag=' + x);
                    switch (resultTag) {
                        case 1: msg = '删除成功!'; break;
                        case 2: msg = '删除失败，请重试!'; break;
                        case 4: msg = '已勾选为系统，无法删除！'; break;
                        case 5: msg = '该表属于系统保留不允许删除！'; break;
                        case 6: msg = '请先删除列和行后再删除表格!'; break;
                    }

                    if (resultTag != 1) {
                      showMsg2(msg);
                    } else {
                        td.style.display = 'none';
                    }
                });
        }
    }
    function getId(s) {
        return s.parentNode.parentNode.childNodes[0].innerHTML;
    }
  </script>



	</body>
</html>